package uk.co.accolade.test.threads;

import uk.co.accolade.test.threads.ControllableThread;

public class RunHandler {

    private StopCondition stopCondition;
    private ControllableThread controllableThread;
    private PostRunVerify postRunVerify;

    public RunHandler( StopCondition stopCondition, ControllableThread controllableThread, PostRunVerify postRunVerify ) {
        this.stopCondition = stopCondition;
        this.controllableThread = controllableThread;
        this.postRunVerify = postRunVerify;
    }

    public void start() {
        stopCondition.registerControllableThread( this );
        controllableThread.start();
//        Thread t = new Thread( runnable );
//        t.start();
    }

    public void stop() {
        controllableThread.stop();
        postRunVerify.verify();
    }
}
